package com.giscloud.amp.controller.user;

import cn.hutool.core.collection.CollectionUtil;
import com.giscloud.amp.controller.BaseController;
import com.giscloud.amp.entity.AmpStaffAuth;
import com.giscloud.amp.entity.AmpStaffExample;
import com.giscloud.amp.entity.AmpStaffRole;
import com.giscloud.amp.entity.dto.*;
import com.giscloud.amp.entity.vo.AmpStaffAuthVO;
import com.giscloud.amp.entity.vo.AmpStaffVO;
import com.giscloud.amp.entity.vo.SysRegisterVO;
import com.giscloud.amp.service.auth.*;
import com.giscloud.amp.service.sys.SysRegisterService;
import com.giscloud.commons.model.Result;
import com.giscloud.commons.utils.StringUtils;
import com.giscloud.datasource.page.PageInfo;
import com.giscloud.token.utils.Token;
import com.giscloud.token.utils.TokenUserUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author:gxd
 * @Description:
 * @Date: 10:19 2018/2/14
 * @Modified By:
 */
@SuppressWarnings("SpringJavaAutowiringInspection")
@Controller
public class SystemUserController extends BaseController {
	@Autowired
	private AmpStaffService ampStaffRemoteClient;
	@Autowired
	private SysRegisterService sysRegisterRemoteClient;
	@Autowired
	private AmpStaffRoleService ampStaffRoleRemoteClient;
	@Autowired
	private AmpStaffAuthService ampStaffAuthRemoteClient;
	@Autowired
	private AmpStaffOrgService ampStaffOrgRemoteClient;
	@Autowired
	private AmpPwChgTypeService ampPwChgTypeRemoteClient;

	@Autowired
	private TokenUserUtil tokenUserUtil;
	@Value("${gxd.sso.adminId:0}")
	private Long adminId;


	@RequestMapping(value = "/amp/sysUser/getAmpStaffList", method = RequestMethod.POST)
	@ResponseBody
	public PageInfo getSystemUsers(@RequestBody AmpStaffDTO ampStaffDTO) {
		ampStaffDTO.setUserId(tokenUserUtil.getUserId());
		PageInfo ampStaffList = ampStaffRemoteClient.getAmpStaffList(ampStaffDTO);
		return ampStaffList;
	}

	@RequestMapping(value = "/amp/sysUser/add", method = RequestMethod.POST)
	@ResponseBody
	public Result add(@RequestBody AmpStaffDTO ampStaffDTO) {
		Result result = new Result();
		String loginName = ampStaffDTO.getLoginName();
			List<AmpStaffVO> ampStaffVOList = ampStaffRemoteClient
					.getAmpStaffByStaffName(loginName);
			if(ampStaffVOList!=null && ampStaffVOList.size()>0){
				result.setMsg("该用户名已已经注册，添加失败");
				result.setCode(-1);
				result.setSuccess(false);
				return result;
			}
			//判断电话重复
			AmpStaffExample ampStaffExample = new AmpStaffExample();
			AmpStaffExample.Criteria criteria = ampStaffExample.createCriteria();
			criteria.andTelephoneEqualTo(ampStaffDTO.getTelephone());
			Long count = ampStaffRemoteClient.countByPhone(ampStaffExample);
			if(count >= 1){
				result.setMsg("该电话已被使用,添加失败");
				result.setCode(-1);
				result.setSuccess(false);
				return result;
			}

			ampStaffDTO.setCreatedStaffId(tokenUserUtil.getUserId());
			if (ampStaffRemoteClient.insert(ampStaffDTO) >= 1) {
				result.setMsg("提交成功");
				result.setCode(0);
				result.setSuccess(true);
			} else {
				result.setMsg("提交失败");
				result.setCode(-1);
				result.setSuccess(false);
			}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/edit", method = RequestMethod.POST)
	@ResponseBody
	public Result edit(@RequestBody AmpStaffDTO ampStaffDTO) {
		Result result = new Result();
		long statusCd = ampStaffDTO.getStatusCd();
			ampStaffDTO.setStatusCd(null);
			String loginName = ampStaffDTO.getLoginName();
			List<AmpStaffVO> ampStaffVOList = ampStaffRemoteClient
					.getAmpStaffByStaffName(loginName);
			if (ampStaffVOList.size() > 1) {
				result.setMsg("该用户名已已经注册,更新失败");
				result.setCode(-1);
				result.setSuccess(false);
				return result;
			}
			//判断电话重复
			AmpStaffExample ampStaffExample = new AmpStaffExample();
			AmpStaffExample.Criteria criteria = ampStaffExample.createCriteria();
			criteria.andTelephoneEqualTo(ampStaffDTO.getTelephone());
			criteria.andStaffIdNotEqualTo(ampStaffDTO.getStaffId());
			Long count = ampStaffRemoteClient.countByPhone(ampStaffExample);
			if(count >= 1){
				result.setMsg("该电话已被使用,更新失败");
				result.setCode(-1);
				result.setSuccess(false);
				return result;
			}
			AmpStaffVO ampStaffVO = ampStaffRemoteClient
					.getAmpStaffByCondition(ampStaffDTO);
			ampStaffDTO.setOldValue(StringUtils.getOldValue(ampStaffVO));
			ampStaffDTO.setCreatedStaffId(tokenUserUtil.getUserId());
			ampStaffDTO.setCreatedDt(ampStaffVO.getCreatedDt());
			ampStaffDTO.setStatusCd(statusCd);
			if (ampStaffRemoteClient.update(ampStaffDTO) >= 1) {
				result.setMsg("更新成功");
				result.setCode(0);
				result.setSuccess(true);
			} else {
				result.setMsg("更新失败");
				result.setCode(-1);
				result.setSuccess(false);
			}
		return result;
	}

	/**
	 * 删除用户只是做更新操作
	 * @param ampStaffDTO
	 * @return
	 */
	@RequestMapping(value = "/amp/sysUser/delete", method = RequestMethod.POST)
	@ResponseBody
	public Result delete(@RequestBody AmpStaffDTO ampStaffDTO) {
		Result result = new Result();
		if (ampStaffDTO.getStaffId() == null) {
			result.setMsg("删除失败，用户ID不能为空");
			result.setCode(-1);
			result.setSuccess(false);
			return result;
		}
		ampStaffRemoteClient.delete(ampStaffDTO.getStaffId());
		result.setMsg("删除成功");
		result.setCode(0);
		result.setSuccess(true);
		return result;
	}

	/**
	 * 得到ModelAndView
	 */

	@RequestMapping(value = "/amp/sysUser/rolePageList")
	public Result rolePage(@RequestBody AmpStaffDTO ampStaffDTO)
			throws Exception {

		if (ampStaffDTO.getStaffId() == null) {
			return Result.error(-1,"staffId 不能为空");
		}
		List<SysRegisterVO> sysRegisterVOS = null;
		Long staff = tokenUserUtil.getUserId();
		if(adminId.equals(staff)){
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegister();
		}else{
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegisterByStaff(staff);
		}
		List<Map> list = Lists.newArrayListWithCapacity(8);
		for (SysRegisterVO sysRegisterVO : sysRegisterVOS) {
			Map map = Maps.newHashMapWithExpectedSize(2);
			map.put("systemId",sysRegisterVO.getSystemId());
			map.put("systemName",sysRegisterVO.getSystemName());
			list.add(map);
		}
		return Result.success(list);
	}

	@RequestMapping(value = "/amp/sysUser/getAmpStaffRoleList", method = RequestMethod.POST)
	@ResponseBody
	public PageInfo getAmpStaffRoleList(
			@RequestBody AmpStaffRoleDTO ampStaffRoleDTO) {
		return ampStaffRoleRemoteClient
				.getAmpStaffRoleListByDTO(ampStaffRoleDTO);
	}

	@RequestMapping(value = "/amp/sysUser/userRoleAdd", method = RequestMethod.POST)
	@ResponseBody
	public Result userRoleAdd(@RequestBody AmpStaffRoleDTO ampStaffRoleDTO) {
		Result result = new Result();
			ampStaffRoleDTO.setCreatedStaffId(tokenUserUtil.getUserId());
			ampStaffRoleDTO.setOpreateStaffId(tokenUserUtil.getUserId());
			if (ampStaffRoleRemoteClient.insert(ampStaffRoleDTO) >= 1) {
				result.setMsg("操作成功");
				result.setCode(0);
				result.setSuccess(true);
			} else {
				result.setMsg("操作失败");
				result.setCode(-1);
				result.setSuccess(false);
			}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/batUserRoleAdd", method = RequestMethod.POST)
	@ResponseBody
	public Result batUserRoleAdd(@RequestBody List<AmpStaffRoleDTO> ampStaffRoleDTOList) {
		Result result = new Result();


			if (!ampStaffRoleDTOList.isEmpty()
					&& ampStaffRoleDTOList.size() != 0) {
				List<AmpStaffRole> insertAmpStaffRoles = new ArrayList<>();
				List<AmpStaffRole> updateAmpStaffRoles = new ArrayList<>();
				for (int i = 0; i < ampStaffRoleDTOList.size(); i++) {
					AmpStaffRoleDTO ampStaffRoleDTO = ampStaffRoleDTOList
							.get(i);
					if (ampStaffRoleDTO.getRelId() == -1) {
						ampStaffRoleDTO.setCreatedStaffId(getToken()
								.getStaffId());
						ampStaffRoleDTO.setOpreateStaffId(getToken()
								.getStaffId());
						AmpStaffRole ampStaffRole = new AmpStaffRole();
						BeanUtils.copyProperties(ampStaffRoleDTO, ampStaffRole);
						ampStaffRole.setCreatedDt(new Date());
						ampStaffRole.setVersion(new Date());
						insertAmpStaffRoles.add(ampStaffRole);
					} else {
						ampStaffRoleDTO.setOpreateStaffId(getToken()
								.getStaffId());
						AmpStaffRole ampStaffRole = new AmpStaffRole();
						BeanUtils.copyProperties(ampStaffRoleDTO, ampStaffRole);
						ampStaffRole.setVersion(new Date());
						updateAmpStaffRoles.add(ampStaffRole);
					}
				}
				if (CollectionUtil.isNotEmpty(insertAmpStaffRoles)) {
					if (ampStaffRoleRemoteClient
							.batchInsert(insertAmpStaffRoles) >= 1) {
						result.setMsg("操作成功");
						result.setCode(0);
						result.setSuccess(true);
					} else {
						result.setMsg("操作失败");
						result.setCode(-1);
						result.setSuccess(false);
					}
				}
				if (CollectionUtil.isNotEmpty(updateAmpStaffRoles)) {
					if (ampStaffRoleRemoteClient
							.batchUpdate(updateAmpStaffRoles) >= 1) {
						result.setMsg("操作成功");
						result.setCode(0);
						result.setSuccess(true);
					} else {
						result.setMsg("操作失败");
						result.setCode(-1);
						result.setSuccess(false);
					}
				}
			}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userRoleEdit", method = RequestMethod.POST)
	@ResponseBody
	public Result userRoleEdit(@RequestBody AmpStaffRoleDTO ampStaffRoleDTO) {
		Result result = new Result();
		ampStaffRoleDTO.setOpreateStaffId(tokenUserUtil.getUserId());
		if (ampStaffRoleRemoteClient.update(ampStaffRoleDTO) >= 1) {
			result.setMsg("操作成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("操作失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userRoleDel", method = RequestMethod.POST)
	@ResponseBody
	public Result userRoleDel(@RequestBody AmpStaffRoleDTO ampStaffRoleDTO) {
		Result result = new Result();
		if (ampStaffRoleDTO.getRelId() == null) {
			result.setMsg("删除失败，关系ID不能为空");
			result.setCode(-1);
			result.setSuccess(false);
			return result;
		}
		if (ampStaffRoleRemoteClient.delete(ampStaffRoleDTO.getRelId()) >= 1) {
			result.setMsg("删除成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("删除失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	/**
	 * 得到ModelAndView
	 */
	@RequestMapping(value = "/amp/sysUser/authPageList")
	public Result authPage(@RequestBody AmpStaffRoleDTO ampStaffRoleDTO){
		if (ampStaffRoleDTO.getStaffId() == null) {
			return Result.error(-1,"staffId 不能为空");
		}
		List<SysRegisterVO> sysRegisterVOS = null;
		Token ssoToken = getToken();
		Long staff = ssoToken.getStaffId();
		if(adminId.equals(staff)){
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegister();
		}else{
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegisterByStaff(staff);
		}
		List<Map> list = Lists.newArrayListWithCapacity(8);
		for (SysRegisterVO sysRegisterVO : sysRegisterVOS) {
			Map map = Maps.newHashMapWithExpectedSize(2);
			map.put("systemId",sysRegisterVO.getSystemId());
			map.put("systemName",sysRegisterVO.getSystemName());
			list.add(map);
		}

		return Result.success(list);
	}

	/**
	 * 根据用户id获取权限树,只能看到拥有的权限树03-04
	 * @param ampStaffAuthDTO
	 * @return
	 */
	@RequestMapping(value = "/amp/sysUser/findAmpStaffAuthList")
	@ResponseBody
	public List<AmpStaffAuthVO> findAmpStaffAuthList(@RequestBody AmpStaffAuthDTO ampStaffAuthDTO) {
		if (ampStaffAuthDTO.getObjectId() == null
				|| ampStaffAuthDTO.getSystemId() == null) {
			List<AmpStaffAuthVO> alist = new ArrayList<>();
			return alist;
		}
		ampStaffAuthDTO.setStaffId(tokenUserUtil.getUserId());
		ampStaffAuthDTO.setObjectType((short) 1);
		List<AmpStaffAuthVO> list = ampStaffAuthRemoteClient
				.findAmpStaffAuthList(ampStaffAuthDTO);
		return list;
	}

	@RequestMapping(value = "/amp/sysUser/userAuthAdd", method = RequestMethod.POST)
	@ResponseBody
	public Result userAuthAdd(@RequestBody AmpStaffAuthDTO ampStaffAuthDTO) {
		Result result = new Result();
		try {
			ampStaffAuthDTO.setCreatedStaffId(tokenUserUtil.getUserId());
			ampStaffAuthDTO.setOpreateStaffId(tokenUserUtil.getUserId());
			int i = ampStaffAuthRemoteClient.insert(ampStaffAuthDTO);
			if (i >= 1) {
				result.setMsg("操作成功");
				result.setCode(0);
				result.setSuccess(true);
			} else {
				result.setMsg("操作失败");
				result.setCode(-1);
				result.setSuccess(false);
			}
		} catch (Exception e) {
			result.setMsg("操作失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userAuthEdit", method = RequestMethod.POST)
	@ResponseBody
	public Result userAuthEdit(@RequestBody AmpStaffAuthDTO ampStaffAuthDTO) {
		Result result = new Result();
		try {
			ampStaffAuthDTO.setOpreateStaffId(tokenUserUtil.getUserId());
			if (ampStaffAuthRemoteClient.update(ampStaffAuthDTO) >= 1) {
				result.setMsg("操作成功");
				result.setCode(0);
				result.setSuccess(true);
			} else {
				result.setMsg("操作失败");
				result.setCode(-1);
				result.setSuccess(false);
			}
		} catch (Exception e) {
			result.setMsg("操作失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userAuthDel", method = RequestMethod.POST)
	@ResponseBody
	public Result userAuthDel(@RequestBody AmpStaffRoleDTO ampStaffRoleDTO) {
		Result result = new Result();
		if (ampStaffRoleDTO.getRelId() == null) {
			result.setMsg("删除失败，关系ID不能为空");
			result.setCode(-1);
			result.setSuccess(false);
			return result;
		}
		if (ampStaffAuthRemoteClient.delete(ampStaffRoleDTO.getRelId()) >= 1) {
			result.setMsg("删除成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("删除失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	/**
	 * 批量更新用户所拥有的权限
	 * 
	 * @param ampStaffAuthDTOList
	 * @return
	 */
	@RequestMapping(value = "/amp/sysUser/batUserAuthAdd", method = RequestMethod.POST)
	@ResponseBody
	public Result batUserAuthAdd(@RequestBody List<AmpStaffAuthDTO> ampStaffAuthDTOList) {
		Result result = new Result();

		if (CollectionUtil.isNotEmpty(ampStaffAuthDTOList)) {
			List<AmpStaffAuthDTO> insertAmpStaffAuths = new ArrayList<>();
			List<AmpStaffAuthDTO> updateAmpStaffAuths = new ArrayList<>();
			for (int i = 0; i < ampStaffAuthDTOList.size(); i++) {
				AmpStaffAuthDTO ampStaffAuthDTO = ampStaffAuthDTOList
						.get(i);
				if (ampStaffAuthDTO.getRelId() == -1) {
					ampStaffAuthDTO.setCreatedStaffId(getToken()
							.getStaffId());
					ampStaffAuthDTO.setOpreateStaffId(getToken()
							.getStaffId());
					AmpStaffAuth ampStaffAuth = new AmpStaffAuth();
					BeanUtils.copyProperties(ampStaffAuthDTO, ampStaffAuth);
					ampStaffAuthDTO.setCreatedDt(new Date());
					ampStaffAuthDTO.setVersion(new Date());
					insertAmpStaffAuths.add(ampStaffAuthDTO);
				} else {
					ampStaffAuthDTO.setOpreateStaffId(getToken()
							.getStaffId());
					AmpStaffAuthDTO ampStaffAuth = new AmpStaffAuthDTO();
					BeanUtils.copyProperties(ampStaffAuthDTO, ampStaffAuth);
					ampStaffAuth.setVersion(new Date());
					updateAmpStaffAuths.add(ampStaffAuth);
				}
			}
			if (CollectionUtil.isNotEmpty(insertAmpStaffAuths)) {
				if (ampStaffAuthRemoteClient
						.batchInsert(insertAmpStaffAuths) >= 1) {
					result.setMsg("操作成功");
					result.setCode(0);
					result.setSuccess(true);
				} else {
					result.setMsg("操作失败");
					result.setCode(-1);
					result.setSuccess(false);
				}
			}
			if (CollectionUtil.isNotEmpty(updateAmpStaffAuths)) {
				if (ampStaffAuthRemoteClient
						.batchUpdate(updateAmpStaffAuths) >= 1) {
					result.setMsg("操作成功");
					result.setCode(0);
					result.setSuccess(true);
				} else {
					result.setMsg("操作失败");
					result.setCode(-1);
					result.setSuccess(false);
				}
			}
		}
		return result;
	}

	/**
	 * 页面
	 */
	@RequestMapping(value = "/amp/sysUser/userOrgList")
	public Result userOrg(){

		List<SysRegisterVO> sysRegisterVOS = null;
		Token ssoToken = getToken();
		Long staff = ssoToken.getStaffId();
		if(adminId.equals(staff)){
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegister();
		}else{
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegisterByStaff(staff);
		}
		List<Map> list = Lists.newArrayListWithCapacity(8);
		for (SysRegisterVO sysRegisterVO : sysRegisterVOS) {
			Map map = Maps.newHashMapWithExpectedSize(2);
			map.put("systemId",sysRegisterVO.getSystemId());
			map.put("systemName",sysRegisterVO.getSystemName());
			list.add(map);
		}
		return Result.success(list);
	}

	@RequestMapping(value = "/amp/sysUser/userOrgAdd", method = RequestMethod.POST)
	@ResponseBody
	public Result batUserAuthAdd(@RequestBody AmpStaffOrgDTO ampStaffOrgDTO) {
		Result result = new Result();
		ampStaffOrgDTO.setCreatedStaffId(tokenUserUtil.getUserId());
		ampStaffOrgDTO.setOpreateStaffId(tokenUserUtil.getUserId());
		if (ampStaffOrgRemoteClient.insert(ampStaffOrgDTO) >= 1) {
			result.setMsg("操作成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("操作失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userPasswordReset", method = RequestMethod.POST)
	@ResponseBody
	public Result userPasswordReset(@RequestBody AmpStaffDTO ampStaffDTO) {
		Result result = new Result();
		ampStaffDTO.setCreatedStaffId(tokenUserUtil.getUserId());
		if (ampStaffRemoteClient.resetPassword(ampStaffDTO) >= 1) {
			result.setMsg("重置成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("重置失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/getAmpStaffForValidate", method = RequestMethod.POST)
	@ResponseBody
	public Result getAmpStaffForValidate(@RequestBody AmpStaffDTO ampStaffDTO) {
		Result result = new Result();
		AmpStaffVO ampStaffVo = ampStaffRemoteClient
				.getAmpStaffForValidate(ampStaffDTO);
		if (ampStaffVo != null) {
			result.setMsg("用户存在");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("用户不存在");
			result.setCode(0);
			result.setSuccess(false);
		}
		return result;
	}



	@RequestMapping(value = "/amp/sysUser/getAmpPwChgTypeList", method = RequestMethod.POST)
	@ResponseBody
	public PageInfo getAmpPwChgTypeList(
			@RequestBody AmpPwChgTypeDTO ampPwChgTypeDTO) {
		return ampPwChgTypeRemoteClient.getAmpPwChgTypeList(ampPwChgTypeDTO);
	}

	@RequestMapping(value = "/amp/sysUser/userPwChgTypeAdd", method = RequestMethod.POST)
	@ResponseBody
	public Result userPwChgTypeAdd(AmpPwChgTypeDTO ampPwChgTypeDTO) {
		Result result = new Result();
		ampPwChgTypeDTO.setCreatedStaffId(tokenUserUtil.getUserId());
		if (ampPwChgTypeRemoteClient.insert(ampPwChgTypeDTO) >= 1) {
			result.setMsg("操作成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("操作失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userPwChgTypeEdit", method = RequestMethod.POST)
	@ResponseBody
	public Result userPwChgTypeEdit(@RequestBody AmpPwChgTypeDTO ampPwChgTypeDTO) {
		Result result = new Result();
		ampPwChgTypeDTO.setCreatedStaffId(tokenUserUtil.getUserId());
		if (ampPwChgTypeRemoteClient.update(ampPwChgTypeDTO) >= 1) {
			result.setMsg("操作成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("操作失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	@RequestMapping(value = "/amp/sysUser/userPwChgTypeDel", method = RequestMethod.POST)
	@ResponseBody
	public Result userPwChgTypeDel(@RequestBody AmpPwChgTypeDTO ampPwChgTypeDTO) {
		Result result = new Result();
		if (ampPwChgTypeDTO.getPwChgTypeId() == null) {
			result.setMsg("删除失败，pwChgTypeId不能为空");
			result.setCode(-1);
			result.setSuccess(false);
			return result;
		}
		if (ampPwChgTypeRemoteClient.delete(ampPwChgTypeDTO.getPwChgTypeId()) >= 1) {
			result.setMsg("删除成功");
			result.setCode(0);
			result.setSuccess(true);
		} else {
			result.setMsg("删除失败");
			result.setCode(-1);
			result.setSuccess(false);
		}
		return result;
	}

	/**
	 * 得到ModelAndView
	 */
	@RequestMapping(value = "/amp/sysUser/staffDataList")
	public Result staffData(){
		List<SysRegisterVO> sysRegisterVOS = null;
		Token ssoToken = getToken();
		Long staff = ssoToken.getStaffId();
		if(adminId.equals(staff)){
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegister();
		}else{
			sysRegisterVOS = sysRegisterRemoteClient.listSysRegisterByStaff(staff);
		}
		List<Map> list = Lists.newArrayListWithCapacity(8);
		for (SysRegisterVO sysRegisterVO : sysRegisterVOS) {
			Map map = Maps.newHashMapWithExpectedSize(2);
			map.put("systemId",sysRegisterVO.getSystemId());
			map.put("systemName",sysRegisterVO.getSystemName());
			list.add(map);
		}
		return Result.success(list);
	}

}
